package com.dream.keigezhushou.Activity.acty.personal;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.dream.keigezhushou.Activity.BaseActivity;
import com.dream.keigezhushou.R;

import butterknife.BindView;
import butterknife.ButterKnife;

public class MyEvaluateActivity extends BaseActivity {

    @BindView(R.id.iv_return)
    ImageView ivReturn;
    @BindView(R.id.tv_title)
    TextView tvTitle;
    @BindView(R.id.lv_evaluate)
    ListView lvEvaluate;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_evaluate);
        ButterKnife.bind(this);

        initView();
        initData();
    }

    //初始化界面
    protected void initView(){

        tvTitle.setText("待评价");
    }

    //初始化数据
    protected void initData(){

        ivReturn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                //返回
                finish();
            }
        });

        //ListView创建适配器
        lvEvaluate.setAdapter(new EvaluateAdapter(this));
    }

    public class EvaluateAdapter extends BaseAdapter {

        private Context mContext;

        int c = 10;
        public EvaluateAdapter(Context context) {
            this.mContext = context;
        }

        @Override
        public int getCount() {
            return c;
        }

        @Override
        public Object getItem(int i) {
            return i;
        }

        @Override
        public long getItemId(int i) {
            return i;
        }

        @Override
        public View getView(int i, View view, ViewGroup viewGroup) {

            ViewHolder mHolder = null;
            if (view == null){

                view = LayoutInflater.from(mContext).inflate(R.layout.layout_order_item,null);

                mHolder = new ViewHolder();
                mHolder.tvKind = (TextView)view.findViewById(R.id.tv_state_kind);
                mHolder.tvStyle = (TextView)view.findViewById(R.id.tv_style);
                mHolder.rlState = (RelativeLayout)view.findViewById(R.id.rl_state_kind);

                view.setTag(mHolder);
            }else {

                mHolder = (ViewHolder)view.getTag();
            }

            mHolder.tvKind.setText("待评价");
            mHolder.tvStyle.setText("去评价");

            mHolder.rlState.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {

                    Intent intent = new Intent(mContext,CommitEvaluateActivity.class);
                    startActivity(intent);
                }
            });
            return view;
        }

        class ViewHolder{

            TextView tvKind,tvStyle;
            RelativeLayout rlState;

        }
    }
}
